home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / DIVS.S < prev    next >
Text File  |  1989-04-27  |  1KB  |  57 lines

  1. ******************************************************************************
  2. * divs.s 3.1 11/12/84 
  3. *
  4. *        68HC11 CROSS C COMPILER RUN-TIME LIBRARY
  5. *
  6. *           (c) Copyright 1984, Motorola, Inc.
  7. *
  8. *  FUNCTION NAME:    .divs
  9. *
  10. *  ACTION:        Calculate the quotient of two 8-bit signed integers.
  11. *
  12. *  REGISTERS AND STACK:
  13. *
  14. *  ON ENTRY:    X:    FP (frame pointer)
  15. *        B:    Dividend
  16. *        A:    Divisor
  17. *
  18. *        STACK:      Return Address
  19. *        SP:    
  20. *
  21. *  ON EXIT:    X:    FP 
  22. *        Y:    Preserved
  23. *        B:    Quotient
  24. *
  25. *        STACK:    Previous Contents
  26. *        SP:    
  27. *
  28. ******************************************************************************
  29.     psct
  30.     xdef    .divs
  31. .divs:
  32.     pshx        save FP
  33.     psha        save sign of divisor
  34.     tsta        is divisor > 0?
  35.     bpl    *+3    yes
  36.     nega        no..negate
  37.     psha        copy..
  38.     clra        ..divisor
  39.     psha        ..to
  40.     pulx        ..X
  41.     tstb        is dividend > 0?
  42.     bpl    div1    yes
  43.     negb        no..negate and..
  44.     pula        ..complement
  45.     coma        ..sign bit
  46.     psha
  47.     clra
  48. div1:    idiv        do division D/X
  49.     xgdx        get quotient
  50.     pula        recover sign
  51.     tsta        is sign positive?
  52.     bpl    *+3    yes
  53.     negb        no..negate quotient
  54.     pulx        restore FP
  55.     rts        return
  56.     end
  57.